import request from '@/utils/request'
import type { IAddArticleCate, IUpdateArticleCate, IArticle, IArticleEcho } from './type'

// 获取文章分类
export const getArticleCateService = () => request.get('/my/cate/list')

// 添加文章分类
export const addArticleCateService = (data: IAddArticleCate) => request.post('/my/cate/add', data)

// 编辑文章分类
export const updateArticleCateService = (data: IUpdateArticleCate) =>
  request.put('/my/cate/info', data)

// 删除文章分类 query参数需要在我们对象params中传递
export const deleteArticleCateService = (id: number) =>
  request.delete('/my/cate/del', {
    params: {
      id
    }
  })

// 获取文章列表
export const artGetListService = (params: any) => request.get('/my/article/list', { params })

// 发布文章
export const artAddService = (data: IArticle) => request.post('/my/article/add', data)

// 编辑文章回显
export const artGetDetailService = (id: IArticleEcho) =>
  request.get('my/article/info', { params: { id } })

// 编辑文章
export const artEditService = (data: object) => request.put('my/article/info', data)

// 删除文章
export const artDelService = (id: string) =>
  request.delete('/my/article/info', {
    params: {
      id
    }
  })
